# https://leetcode-cn.com/problems/two-sum/
from typing import List, Dict

class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        hashmap = {}  # type: Dict[int, int]
        for i, n in enumerate(nums):
            j = hashmap.get(target - n)
            if j is not None:
                return [j, i]
            hashmap[n] = i
        return []


if __name__ == "__main__":
    nums = [2, 7, 11, 15]
    target = 9
    res = Solution().twoSum(nums, target)
    print(res)
